import { WeaTools } from 'ecCom';
import window from '../util';
export const newUrl = '/api/cube/'
export const CallAPI = (url, method, params) => {
    return new Promise((resolve, reject) => {
        WeaTools.callApi(url, method, params).then(({ noRight, ...data }) => {
            if (noRight) {
                reject();
                window.weaHistory.push('/main/cube/noright');
            } else {
                resolve(data as any)
            }
        })
    })
}

export const getTabs = (params) => {
    return CallAPI(`${newUrl}tab/getTabs`, "get", params);
}
export const updateDataTab = (params) => {
    return CallAPI(`${newUrl}tab/updateDataTab`, "post", params);
}
export const saveSingtonTab = (params) => {
    return CallAPI(`${newUrl}tab/saveSingtonTab`, "post", params);
}
export const delSingtonTab = (params) => {
    return CallAPI(`${newUrl}tab/delSingtonTab`, "post", params);
}


